<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //冒泡排序
    let arr = [3,2,4,1,5,6];
    let temp; //中间容器
    for(let i=0; i<arr.length;i++){  //控制比较伦教
        for(let j=0; j<arr.length-i;j++){
            if(arr[j]>arr[j+1]){
                temp = arr[j];
                arr[j] = arr[j+1];
                arr[j+1] = temp;
            }        }
    }
    console.log(arr);
    //插入排序
    let newarr = [3,2,4,1,5,6];
    let tem;
    for(let i=0; i<newarr.length;i++){
        for(let j=i;j>0;j--){
            if(newarr[j]>newarr[j-1]){
                temp = newarr[j];
                newarr[j] = newarr[j-1];
                newarr[j-1] = temp;
            }
        }
    }
</script>
</html>